package com.wyz.service;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wyz.entity.Log;
import com.wyz.entity.StudentEntity;
import com.wyz.mapper.LogMapper;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import java.util.List;

@Service
@RequestMapping("/log")
public class LogService {
    @Resource
    private LogMapper logMapper;
    public void add(Log log) {
        logMapper.insert(log);
    }
    public List<Log> listAll() {
        return logMapper.selectList(null); // 使用MyBatis Plus的selectList方法
    }
     // 根据 ID 删除日志
    public void deleteLog(Integer id) {
        logMapper.deleteById(id);
    }


    @GetMapping("/list")
    public IPage<Log> getLogListByPage(int currentPage) {
        IPage<Log> page = new Page<>(currentPage,5);
        IPage<Log> logListPage = logMapper.selectPage(page,null);
        return logListPage;
    }
}